package cj.web.tb.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.tb.domain.TBRaterRegistration;

/**
 * 
 * @author 
 *
 */
@DAO
public interface TBRaterRegistrationDAO{
	
	@SQL("SELECT * FROM TBRaterRegistration WHERE deleteFlag=1 #if(:t.name != null){ AND name LIKE '%##(:t.name)%' } #if(:t.userId != null){ AND userId =:t.userId } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<TBRaterRegistration> queryByUserId(@SQLParam("t") TBRaterRegistration tBRaterRegistration);
	
	@SQL("SELECT count(1) FROM TBRaterRegistration WHERE deleteFlag=1 #if(:t.name != null){ AND name LIKE '%##(:t.name)%' } #if(:t.userId != null){ AND userId =:t.userId } ")
    int queryByUserIdSize(@SQLParam("t") TBRaterRegistration tBRaterRegistration);
	
	@SQL("SELECT * FROM TBRaterRegistration WHERE deleteFlag=1 #if(:t.name != null){ AND name LIKE '%##(:t.name)%' } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<TBRaterRegistration> query(@SQLParam("t") TBRaterRegistration tBRaterRegistration);
	
	@SQL("SELECT count(1) FROM TBRaterRegistration WHERE deleteFlag=1 #if(:t.name != null){ AND name LIKE '%##(:t.name)%' } ")
    int querySize(@SQLParam("t") TBRaterRegistration tBRaterRegistration);
    
    @SQL("select * from TBRaterRegistration where id=:1")
    TBRaterRegistration queryById(int id);
    
    @SQL("INSERT INTO TBRaterRegistration (userId,photo,name,type,resume,remark,status,deleteFlag,createAt,createUser,updateAt,updateUser) VALUES (:t.userId,:t.photo,:t.name,:t.type,:t.resume,:t.remark,:t.status,1,now(),:t.createUser,now(),:t.updateUser)")
    void create(@SQLParam("t") TBRaterRegistration tBRaterRegistration);
	
	@SQL("UPDATE TBRaterRegistration SET photo=:t.photo,name=:t.name,type=:t.type,resume=:t.resume,remark=:t.remark,updateAt=now(),updateUser=:t.updateUser,status=:t.status WHERE id=:t.id")
    void update(@SQLParam("t") TBRaterRegistration tBRaterRegistration);
	
	@SQL("UPDATE TBRaterRegistration SET userId=:2,updateAt=now(),updateUser=:3 WHERE id=:1 ")
    void updateUserId(int id, int userId, String updateUser);
	
	@SQL("UPDATE TBRaterRegistration SET status=:2,updateAt=now(),updateUser=:3 WHERE id=:1 ")
    void updateStatus(int id, int status, String updateUser);
    
    @SQL("UPDATE TBRaterRegistration SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
}